package com.globaleducation365.cartoonv1.streaming.network;

import com.globaleducation365.cartoonv1.streaming.NetworkActivity;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

/*
 * <receiver
 android:name="net.viralpatel.network.NetworkChangeReceiver"
 android:label="NetworkChangeReceiver" >
 <intent-filter>
 <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
 <action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
 </intent-filter>
 </receiver>
 */
public class NetworkChangeReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(final Context context, final Intent intent) {
		try {
			String status = NetworkUtil.getConnectivityStatusString(context);
			Toast.makeText(context, status, Toast.LENGTH_LONG).show();
			//launchNetworkError(context);
		} catch (Exception ex) {
		}
	}

	private void launchNetworkError(Context context) {
		Intent vukaniActivity = new Intent(context, NetworkActivity.class);
		vukaniActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
				| Intent.FLAG_ACTIVITY_CLEAR_TOP
				| Intent.FLAG_ACTIVITY_SINGLE_TOP);
		context.startActivity(vukaniActivity);
	}
}